package org.aeon.client.view.components.menuPanel;

import org.aeon.client.context.GlobalContext;
import org.aeon.client.view.components.listColumn.ListColumnPanel;
import org.aeon.client.view.components.sessionPanel.SessionPanel;

import javax.swing.*;
import java.awt.*;

/**
 * @author: MissingAeon
 * @date: 2024/2/20 12:43
 * @description: 菜单
 */
public class MenuPanel extends JPanel {
    public MenuPanel(ListColumnPanel listColumnPanel, SessionPanel sessionPanel) {
        this.setPreferredSize(new Dimension(66, 700));
        this.setLayout(new GridLayout(11, 1, 0, 0));
        final JButton but0 = new JButton("个人");
        but0.setContentAreaFilled(false);
        but0.setBorder(null);
        this.add(but0);
        but0.addActionListener(e -> {
            final PersonalInfoDialog dialog = new PersonalInfoDialog(but0);
            GlobalContext.getContext().getMainUI().addPopUpLayer(dialog);
            dialog.requestFocus();
        });

        final JButton but1 = new JButton("聊天");
        but1.setContentAreaFilled(false);
        but1.setBorder(null);
        but1.addActionListener(e -> {
            final CardLayout layout = (CardLayout) listColumnPanel.getLayout();
            layout.show(listColumnPanel, "MLP");
        });
        this.add(but1);

        final JButton but2 = new JButton("关系");
        but2.setContentAreaFilled(false);
        but2.setBorder(null);
        but2.addActionListener(e -> {
            CardLayout layout = (CardLayout) listColumnPanel.getLayout();
            layout.show(listColumnPanel, "CLP");
        });
        this.add(but2);

        final JButton but3 = new JButton("搜索");
        but3.setContentAreaFilled(false);
        but3.setBorder(null);
        but3.addActionListener(e -> {
            CardLayout layout = (CardLayout) listColumnPanel.getLayout();
            layout.show(listColumnPanel, "SLP");
        });
        this.add(but3);

        // 填充其他网格，使得 "设置" 按钮位于第11个网格
        for (int i = 0; i < 6; i++) {
            this.add(new JLabel()); // 添加空白的占位组件
        }
        final JButton but4 = new JButton("设置");
        but4.setContentAreaFilled(false);
        but4.setBorder(null);
        but4.addActionListener(e -> {
            final SettingsOptionDialog dialog = SettingsOptionDialog.createDialog(but4);
            GlobalContext.getContext().getMainUI().addPopUpLayer(dialog);
        });
        this.add(but4);

        this.setBackground(new Color(0xCAD5D5));

    }
}
